# fire detection yolov5
import io
# Copyright 2021 Huawei Technologies Co., Ltd
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at

# http://www.apache.org/licenses/LICENSE-2.0

# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import json
import os
import time
import cv2
import numpy as np

from flask import Flask, render_template, request, jsonify
from werkzeug.utils import secure_filename

from werkzeug.datastructures import FileStorage

from PIL import Image

import os




app= Flask(__name__)

# visualizatioin settings
HEIGHTALIGNED = 1024
WIDTHALIGNED = 768

# suppression size on area (X*Y)
SIZE = 2304
HUGE_SIZE = SIZE*3





# end of loading

@app.route("/")
def index():
    return render_template('index.html')


@app.route('/fireDetector', methods=['GET', 'POST'])
def recognizer():
    if request.method == 'POST':

        file = request.files['file']

        file_byte = file.stream.read()

        file_memory = io.BytesIO(file_byte)

        image = Image.open(file_memory)

        img = cv2.cvtColor(np.asarray(image), cv2.COLOR_RGB2BGR)

        return render_template('any.html')


if __name__ == '__main__':
    app.run(host="0.0.0.0")
